package com.zzb.text.service;

import com.zzb.text.dao.MenuMapper;
import com.zzb.text.entity.Menu;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by ZZB on 2017/6/16.
 */
@Service
public class MenuService {
    @Autowired
    private MenuMapper menuMapper;

    public List<Menu> list(){
        return menuMapper.findAll();
    }

    public Menu get(String id){
        return menuMapper.getOne(id);
    }

    public void save(Menu menu){
        if(menu.getId() == null || "".equals(menu.getId())){
            menuMapper.insert(menu);
        } else {
            menuMapper.update(menu);
        }
    }

    public void delete(String id){
        menuMapper.delete(id);
    }

}
